package com.qf.rbac2202.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.rbac2202.sys.entity.SysUser;
import com.qf.rbac2202.sys.service.ISysUserService;
import com.qf.rbac2202.utils.PageVo;
import com.qf.rbac2202.utils.R;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 系统用户 前端控制器
 * </p>
 *
 * @author dong_
 * @since 2022-10-28
 */
@RestController
@RequestMapping("/sys/user")
public class SysUserController extends AbstractController{

    @Autowired
    ISysUserService userService;

    @GetMapping("/info")
    public R info(){
        return new R().put("user", getCurrentUser());
    }

    @GetMapping("/list")
    @RequiresPermissions("sys:user:list")  // 权限注解
    public R list(@RequestParam Map<String,String> params){ // 如果使用map接收参数，需要添加 @RequestParam

        PageVo<SysUser> pageVo = userService.queryUserByPage(params);

        return R.ok().put("page", pageVo);

    }

}
